/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MiniCurso.controle;

import MiniCurso.modelo.Usuario;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

/**
 *
 * @author Cassio
 */
@Named("usuario")
@SessionScoped

public class BeanUsuario implements Serializable{
   private String nome;
   private String senha;
   
   public String getNome(){
      return nome;
   }

   public void setNome(String nome){
      this.nome = nome;
   }

   public String getSenha(){
      return senha;
   }

   public void setSenha(String senha){
      this.senha = senha;
   }

  public String valida(){
    if(Usuario.isUsuarioValido(nome, senha)) {
          return "index";
      }
    else {
          return "login";
      }
  }
    public String logout() {  
      Usuario.getSession().invalidate();
      return "/login";
    }  
}